import pymysql

db = pymysql.connect(host='localhost',user='root',password='926979',port=3306,database='test')

cursor = db.cursor()
sql = "UPDATE EMPLOYEE SET AGE = AGE + 1 WHERE SEX = '%c'"%'M'

try:
    cursor.execute(sql)
    db.commit()
except:
    db.rollback()
db.close()